#include <pio.h>
#include <dint.h>
#include <std.h>
#include <error.h>
#include <type.h>
#include <memory.h>
#include <serial.h>
#include <irq.h>
#include <timer.h>

kdrv serial;

static inline void wserial(u16 port,u8 val)
{
	outb(port,val);
}

static inline u8 rserial(u16 port)
{
	return inb(port);
}

static struct com	{
	u16 com1,com2,com3,com4;
}com_info;

int get_com_addr()
{
	u16 *p;
	p=(u16 *)BDA_COM1;
	if(*p)
		com_info.com1=*p;
	p=(u16 *)BDA_COM2;
	if(*p)
		com_info.com2=*p;
	p=(u16 *)BDA_COM3;
	if(*p)
		com_info.com3=*p;
	p=(u16 *)BDA_COM4;
	if(*p)
		com_info.com4=*p;
	return NULL;
}

void serial_com1()
{
}

kdrv serial;
int init_serial()
{
	int i;
	get_com_addr();
	request_irq(&serial,4,serial_com1);
	enable_irq(4);
	return SUCCESS;
}

serialdev serialdevice={
};

kdrv serial={
	.name="serial",
	.init=init_serial,
	.reset=NULL,
	.deinit=NULL,
	.device_irq=4,
	.device=(void *)&serialdevice,
	.device_desc="",
};

__init(serial_init,serial);
